﻿package com.badibadi.adapter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.badibadi.activity.ActivityReadingActivity;
import com.badibadi.activity.CalendarRigionActivity;
import com.badibadi.activity.ClubHomepageActivity;
import com.badibadi.activity.ClubRigionListActivity;
import com.badibadi.activity.LogReadingActivity;
import com.badibadi.activity.PicturePreviewActivity;
import com.badibadi.activity.PinyinSeeActivityTheOriginatorLookParticipantsActivity;
import com.badibadi.activity.RecordListRegionActivity;
import com.badibadi.activity.RegionHomePageActivity;
import com.badibadi.activity.RigionPictureActivity;
import com.badibadi.infos.Area_Main_display_Model;
import com.badibadi.infos.BrowseAllPhoto_Model;
import com.badibadi.mytools.BitmapHelp;
import com.badibadi.mytools.CalendarTools;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.DisplayUtil;
import com.badibadi.uniclubber.R;
import com.google.zxing.oned.rss.FinderPattern;
import com.libjph.util.StringUtil;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

import android.content.Context;
import android.content.Intent;
import android.sax.StartElementListener;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Toast;

//Intent R.layout 1000 Constants
public class RegionHomePageAdapter extends BaseExpandableListAdapter {
	private String img = "http://photo.uniclubber.com/Public/Uploads/2014-10/141416150316618.jpg!imgshow";
	private String[] Group;
	private int[] GroupNumber;
	private int[][] Child = { { R.drawable.ic_launcher },
			{ R.drawable.ic_launcher, R.drawable.ic_launcher },
			{ R.drawable.ic_launcher },
			{ R.drawable.ic_launcher, R.drawable.ic_launcher } };
	private Context context;
	private final int TEXTSIZE_18 = 18;
	private DisplayUtil displayUtil;
	private int dip10_px;
	private int dip5_px;
	private Area_Main_display_Model area_Main_display_Model;

	// private DisplayImageOptions options;

	public RegionHomePageAdapter(Context ct, Area_Main_display_Model area) {
		context = ct;
		Group = new String[] { "",
				context.getResources().getString(R.string.picture),
				context.getResources().getString(R.string.record),
				context.getResources().getString(R.string.club),
				context.getResources().getString(R.string.activity) };
		GroupNumber = new int[5];
		displayUtil = new DisplayUtil();
		area_Main_display_Model = area;
		// options = new DisplayImageOptions.Builder()
		// .showStubImage(R.drawable.ic_stub)
		// .showImageForEmptyUri(R.drawable.noimage)
		// .showImageOnFail(R.drawable.noimage).cacheInMemory()
		// .cacheOnDisc().displayer(new RoundedBitmapDisplayer(5)).build();
		dip10_px = displayUtil.dip2px(context, 10);
		dip5_px = displayUtil.dip2px(context, 5);
		// 获取图片，记录，俱乐部，活动的数量
		try {
			// ("传入数据为:" + area_Main_display_Model.toString());
			for (int j = 0; j < GroupNumber.length; j++) {
				switch (j) {
				case 1:
					if (area_Main_display_Model.getImgs().getPhotoImgNum() != null) {
						GroupNumber[1] = Integer
								.valueOf(area_Main_display_Model.getImgs()
										.getPhotoImgNum());
						// ("数量是:"
						// + area_Main_display_Model.getImgs()
						// .getPhotoImgNum() + " "
						// + GroupNumber[1]);
					}
					break;
				case 2:
					if (area_Main_display_Model.getRecords().getRecordNum() != null) {
						GroupNumber[2] = Integer
								.valueOf(area_Main_display_Model.getRecords()
										.getRecordNum());
						// ("数量是:"
						// + area_Main_display_Model.getRecords()
						// .getRecordNum() + " " + GroupNumber[2]);
					}
					break;
				case 3:
					if (area_Main_display_Model.getClubs().getClubsNum() != null) {
						GroupNumber[3] = Integer
								.valueOf(area_Main_display_Model.getClubs()
										.getClubsNum());
						// ("数量是:"
						// + area_Main_display_Model.getClubs()
						// .getClubsNum() + " " + GroupNumber[3]);
					}
					break;
				case 4:
					if (area_Main_display_Model.getActivity().getActivityNum() != null) {
						GroupNumber[4] = Integer
								.valueOf(area_Main_display_Model.getActivity()
										.getActivityNum());
						// ("数量是:"
						// + area_Main_display_Model.getActivity()
						// .getActivityNum() + " "
						// + GroupNumber[4]);
					}
					break;
				default:
					break;
				}
			}
		} catch (Exception e) {

		}

	}

	@Override
	public int getGroupCount() {
		return Group.length;
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		int pos = 0;
		// 图片的
		if (groupPosition == 1) {
			if (area_Main_display_Model.getImgs() != null) {
				pos = 1;
			}
		}
		// 记录
		if (groupPosition == 2) {
			if (area_Main_display_Model.getRecords().getRecord() != null) {
				pos = area_Main_display_Model.getRecords().getRecord().size();
			}
		}
		// 俱乐部
		if (groupPosition == 3) {
			if (area_Main_display_Model.getClubs() != null) {
				pos = 1;
			}
		}
		// 活动
		if (groupPosition == 4) {
			if (area_Main_display_Model.getActivity().getActivities() != null) {
				pos = area_Main_display_Model.getActivity().getActivities()
						.size();
			}
		}
		return pos;
	}

	@Override
	public View getGroupView(final int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (groupPosition == 0) {
			LayoutInflater inflater = LayoutInflater.from(context);
			View view = inflater.inflate(R.layout.no_image, null);
			ImageView home_page_imageView = (ImageView) view
					.findViewById(R.id.home_page_imageView);
			if (!StringUtil.isNullOrEmpty(area_Main_display_Model.getArea()
					.getBackground())) {
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + area_Main_display_Model.getArea()
				// .getBackground()
				// + Constants.Appactivitycover,
				// home_page_imageView, options);

				new BitmapHelp().displayImage(context, home_page_imageView,
						Constants.BadiDownImgUrl
								+ area_Main_display_Model.getArea()
										.getBackground()
								+ Constants.Appactivitycover);

			} else {
				// ImageLoader.getInstance().displayImage(img,
				// home_page_imageView, options);
				new BitmapHelp()
						.displayImage(context, home_page_imageView, img);
			}

			return view;
		}
		LinearLayout ll = new LinearLayout(context);
		ll.setOrientation(LinearLayout.HORIZONTAL);
		AbsListView.LayoutParams vl = new AbsListView.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		ll.setLayoutParams(vl);
		ll.setBackgroundResource(R.drawable.shape_no_circular_bg2_1dp);
		// 标题（如：图片，记录，俱乐部，活动）
		TextView tv_title = new TextView(context);
		tv_title.setTextSize(TEXTSIZE_18);
		tv_title.setTextColor(context.getResources().getColor(
				R.color.blue_007ea1));
		tv_title.setText(Group[groupPosition]);
		tv_title.setPadding(dip10_px, dip5_px, 0, dip5_px);
		// 标题数量
		TextView tv_number = new TextView(context);
		tv_number.setText("(" + GroupNumber[groupPosition] + ")");
		tv_number.setTextColor(context.getResources().getColor(R.color.gray_9));
		tv_number.setTextSize(TEXTSIZE_18);

		LinearLayout l_fill = new LinearLayout(context);
		LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(0,
				LayoutParams.MATCH_PARENT, 1);
		l_fill.setLayoutParams(lparams);

		LinearLayout l1 = new LinearLayout(context);
		l1.setOrientation(LinearLayout.HORIZONTAL);
		LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
		l1.setLayoutParams(lparams1);
		// 更多
		TextView tv_more = new TextView(context);
		tv_more.setText(context.getResources().getString(R.string.More));
		tv_more.setTextColor(context.getResources().getColor(R.color.gray_9));
		ImageView img = new ImageView(context);
		img.setImageResource(R.drawable.two_jiantou);
		l1.addView(tv_more);

		l1.addView(img);
		l1.setGravity(Gravity.CENTER_VERTICAL);
		l1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Intent intent = null;
				switch (groupPosition) {
				case 1:
					intent = new Intent(context, RigionPictureActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 2:
					intent = new Intent(context, RecordListRegionActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 3:
					intent = new Intent(context, ClubRigionListActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 4:
					intent = new Intent(context, CalendarRigionActivity.class);
					// intent.putExtra("areaid",
					// area_Main_display_Model.getArea()
					// .getId());
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				default:
					break;
				}
				if (intent != null) {
					intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					context.startActivity(intent);
				}
			}
		});
		ll.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = null;
				switch (groupPosition) {
				case 1:
					intent = new Intent(context, RigionPictureActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 2:
					intent = new Intent(context, RecordListRegionActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 3:
					intent = new Intent(context, ClubRigionListActivity.class);
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				case 4:
					intent = new Intent(context, CalendarRigionActivity.class);
					// intent.putExtra("areaid",
					// area_Main_display_Model.getArea()
					// .getId());
					intent.putExtra("areaid", area_Main_display_Model.getArea()
							.getId());
					break;
				default:
					break;
				}
				if (intent != null) {
					intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
					context.startActivity(intent);
				}
			}
		});
		ll.addView(tv_title);
		ll.addView(tv_number);
		ll.addView(l_fill);
		ll.addView(l1);
		return ll;
	}

	@Override
	public View getChildView(int groupPosition, final int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		try {

			LayoutInflater inflater = LayoutInflater.from(context);
			switch (groupPosition) {

			case 0:
				convertView = inflater.inflate(R.layout.no_image, null);
				convertView.findViewById(R.id.home_page_imageView)
						.setVisibility(View.GONE);
				break;
			case 1:// img_group
				convertView = inflater.inflate(
						R.layout.regionhomepage_import_layout0, null);
				if (area_Main_display_Model.getImgs().getPhotoImgNum()
						.equals("0")) {
					convertView.setVisibility(View.GONE);
					convertView.findViewById(R.id.img_group).setVisibility(
							View.GONE);
				}
				// if (childPosition != 0) {
				// convertView.setVisibility(View.GONE);
				// }

				// if (area_Main_display_Model.getImgs().getImgListsCount()
				// .equals("0")
				// && area_Main_display_Model.getImgs().getPhotoImgNum()
				// .equals("0")) {
				// convertView.setVisibility(View.GONE);
				// }
				ImageView regionhomepage_img_1 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_img_1);
				// //
				regionhomepage_img_1
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								// TODO Auto-generated method stub
								List<BrowseAllPhoto_Model> allPhoto_Models = new ArrayList<BrowseAllPhoto_Model>();
								for (int i = 0; i < area_Main_display_Model
										.getImgs().getImgs_Models().size(); i++) {
									BrowseAllPhoto_Model allPhoto_Model = new BrowseAllPhoto_Model();
									allPhoto_Model
											.setId(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getId());
									allPhoto_Model
											.setPath(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getPath());
									allPhoto_Models.add(allPhoto_Model);
								}
								Intent intent = new Intent(context,
										PicturePreviewActivity.class);
								intent.putExtra("picture_list",
										(Serializable) allPhoto_Models);
								intent.putExtra("picture_postion", 0);

								context.startActivity(intent);
							}
						});
				ImageView regionhomepage_img_2 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_img_2);
				regionhomepage_img_2
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								// TODO Auto-generated method stub
								List<BrowseAllPhoto_Model> allPhoto_Models = new ArrayList<BrowseAllPhoto_Model>();
								for (int i = 0; i < area_Main_display_Model
										.getImgs().getImgs_Models().size(); i++) {
									BrowseAllPhoto_Model allPhoto_Model = new BrowseAllPhoto_Model();
									allPhoto_Model
											.setId(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getId());
									allPhoto_Model
											.setPath(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getPath());
									allPhoto_Models.add(allPhoto_Model);
								}
								Intent intent = new Intent(context,
										PicturePreviewActivity.class);
								intent.putExtra("picture_list",
										(Serializable) allPhoto_Models);
								intent.putExtra("picture_postion", 1);

								context.startActivity(intent);
							}
						});
				ImageView regionhomepage_img_3 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_img_3);
				regionhomepage_img_3
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								// TODO Auto-generated method stub

								List<BrowseAllPhoto_Model> allPhoto_Models = new ArrayList<BrowseAllPhoto_Model>();
								for (int i = 0; i < area_Main_display_Model
										.getImgs().getImgs_Models().size(); i++) {
									BrowseAllPhoto_Model allPhoto_Model = new BrowseAllPhoto_Model();
									allPhoto_Model
											.setId(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getId());
									allPhoto_Model
											.setPath(area_Main_display_Model
													.getImgs().getImgs_Models()
													.get(i).getPath());
									allPhoto_Models.add(allPhoto_Model);
								}
								Intent intent = new Intent(context,
										PicturePreviewActivity.class);
								intent.putExtra("picture_list",
										(Serializable) allPhoto_Models);
								intent.putExtra("picture_postion", 2);

								context.startActivity(intent);
							}
						});
				// ("area_Main_display_Model=====>"
				// + area_Main_display_Model);
				if (area_Main_display_Model != null) {
					if (area_Main_display_Model.getImgs().getImgs_Models() != null) {

						for (int i = 0; i < area_Main_display_Model.getImgs()
								.getImgs_Models().size(); i++) {
							// ("图片是:"
							// + area_Main_display_Model.getImgs()
							// .getImgs_Models().get(i).getPath());
							switch (i) {
							case 0:
								// ImageLoader.getInstance().displayImage(
								// Constants.BadiDownImgUrl
								// + area_Main_display_Model
								// .getImgs()
								// .getImgs_Models()
								// .get(0).getPath()
								// + Constants.App9block,
								// regionhomepage_img_1, options);
								new BitmapHelp().displayImage(context,
										regionhomepage_img_1,
										Constants.BadiDownImgUrl
												+ area_Main_display_Model
														.getImgs()
														.getImgs_Models()
														.get(0).getPath()
												+ Constants.App9block);
								break;
							case 1:
								// ImageLoader.getInstance().displayImage(
								// Constants.BadiDownImgUrl
								// + area_Main_display_Model
								// .getImgs()
								// .getImgs_Models()
								// .get(1).getPath()
								// + Constants.App9block,
								// regionhomepage_img_2, options);
								new BitmapHelp().displayImage(context,
										regionhomepage_img_2,
										Constants.BadiDownImgUrl
												+ area_Main_display_Model
														.getImgs()
														.getImgs_Models()
														.get(1).getPath()
												+ Constants.App9block);
								break;
							case 2:
								// ImageLoader.getInstance().displayImage(
								// Constants.BadiDownImgUrl
								// + area_Main_display_Model
								// .getImgs()
								// .getImgs_Models()
								// .get(2).getPath()
								// + Constants.App9block,
								// regionhomepage_img_3, options);
								new BitmapHelp().displayImage(context,
										regionhomepage_img_3,
										Constants.BadiDownImgUrl
												+ area_Main_display_Model
														.getImgs()
														.getImgs_Models()
														.get(2).getPath()
												+ Constants.App9block);
								break;

							default:
								break;
							}
						}
					}
				} else {
					// ("为空");
				}
				break;
			case 2:// 地区的记录regionhomepage_import_background
					// ("记录的项:" + groupPosition);
				convertView = inflater.inflate(
						R.layout.regionhomepage_import_layout1, null);

				if (area_Main_display_Model.getRecords().getRecordNum()
						.equals("0")) {
					convertView.setVisibility(View.GONE);
					break;
				}
				ImageView regionhomepage_import_background = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_background);
				ImageView regionhomepage_import_touxiang = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_touxiang);
				TextView regionhomepage_import_tital = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_tital);
				TextView regionhomepage_import_datatime = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_datatime);
				TextView regionhomepage_import_addressname = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_addressname);
				TextView regionhomepage_import_liulannum = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_liulannum);
				TextView regionhomepage_import_pinglun = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_pinglun);
				TextView regionhomepage_import_zhannum = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_zhannum);
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + area_Main_display_Model.getRecords()
				// .getRecord().get(childPosition)
				// .getImage() + Constants.App9block,
				// regionhomepage_import_background, options);
				new BitmapHelp().displayImage(context,
						regionhomepage_import_background,
						Constants.BadiDownImgUrl
								+ area_Main_display_Model.getRecords()
										.getRecord().get(childPosition)
										.getImage() + Constants.App9block);
				// 记录
				regionhomepage_import_background
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								// TODO Auto-generated method stub
								Intent intent = new Intent(context,
										LogReadingActivity.class);
								intent.putExtra("rid",
										area_Main_display_Model.getRecords()
												.getRecord().get(childPosition)
												.getId());
								intent.putExtra("jilu_fabiao_uid",
										area_Main_display_Model.getRecords()
												.getRecord().get(childPosition)
												.getUid());// 记录发起者的id
								context.startActivity(intent);
							}
						});

				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + area_Main_display_Model.getRecords()
				// .getRecord().get(childPosition)
				// .getModel().getHead()
				// + Constants.App9block,
				// regionhomepage_import_touxiang, options);
				new BitmapHelp().displayImage(context,
						regionhomepage_import_touxiang,
						Constants.BadiDownImgUrl
								+ area_Main_display_Model.getRecords()
										.getRecord().get(childPosition)
										.getModel().getHead()
								+ Constants.App9block);
				regionhomepage_import_tital
						.setText(area_Main_display_Model.getRecords()
								.getRecord().get(childPosition).getTitle());
				regionhomepage_import_datatime.setText(back_time(
						area_Main_display_Model.getRecords().getRecord()
								.get(childPosition).getStart_time(), 0)
						+ "."
						+ back_time(
								area_Main_display_Model.getRecords()
										.getRecord().get(childPosition)
										.getStart_time(), 1)
						+ "."
						+ back_time(
								area_Main_display_Model.getRecords()
										.getRecord().get(childPosition)
										.getStart_time(), 2)
						+ "-"
						+ back_time(area_Main_display_Model.getRecords()
								.getRecord().get(childPosition).getEnd_time(),
								0)
						+ "."
						+ back_time(area_Main_display_Model.getRecords()
								.getRecord().get(childPosition).getEnd_time(),
								1)
						+ "."
						+ back_time(area_Main_display_Model.getRecords()
								.getRecord().get(childPosition).getEnd_time(),
								2));
				regionhomepage_import_addressname
						.setText(area_Main_display_Model.getRecords()
								.getRecord().get(childPosition).getModel()
								.getNickName());
				regionhomepage_import_liulannum.setText(area_Main_display_Model
						.getRecords().getRecord().get(childPosition).getView());
				regionhomepage_import_pinglun.setText(area_Main_display_Model
						.getRecords().getRecord().get(childPosition)
						.getDiscuss());
				regionhomepage_import_zhannum.setText(area_Main_display_Model
						.getRecords().getRecord().get(childPosition)
						.getCollect());
				convertView.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent intent = new Intent(context,
								LogReadingActivity.class);
						intent.putExtra("rid", area_Main_display_Model
								.getRecords().getRecord().get(childPosition)
								.getId());
						intent.putExtra("jilu_fabiao_uid",
								area_Main_display_Model.getRecords()
										.getRecord().get(childPosition)
										.getUid());// 记录发起者的id
						context.startActivity(intent);
					}
				});
				break;
			case 3:// 地区的俱乐部clubOverview_item_img_temp1
					// clubOverview_item_img_temp2

				// intent = new Intent(context, ClubRigionListActivity.class);
				// intent.putExtra("areaid", area_Main_display_Model.getArea()
				// .getId());
				convertView = inflater.inflate(
						R.layout.regionhomepage_import_layout2__1, null);
				if (area_Main_display_Model.getClubs().getClubsNum()
						.equals("0")) {
					convertView.setVisibility(View.GONE);
					convertView.findViewById(R.id.img_group).setVisibility(
							View.GONE);
					break;
				}
				ImageView clubOverview_item_img_temp1 = (ImageView) convertView
						.findViewById(R.id.clubOverview_item_img_temp1);
				ImageView clubOverview_item_img_temp2 = (ImageView) convertView
						.findViewById(R.id.clubOverview_item_img_temp2);
				TextView clubOverview_item_OverAddress_temp1 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_OverAddress_temp1);
				TextView clubOverview_item_OverAddress_temp2 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_OverAddress_temp2);
				TextView clubOverview_item_name_temp1 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_name_temp1);
				TextView clubOverview_item_name_temp2 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_name_temp2);
				TextView clubOverview_item_infos_temp1 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_infos_temp1);
				TextView clubOverview_item_infos_temp2 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_infos_temp2);
				TextView clubOverview_item_addnum_temp1 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_addnum_temp1);
				TextView clubOverview_item_addnum_temp2 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_addnum_temp2);
				TextView clubOverview_item_price_temp1 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_price_temp1);
				TextView clubOverview_item_price_temp2 = (TextView) convertView
						.findViewById(R.id.clubOverview_item_price_temp2);
				LinearLayout xianshi = (LinearLayout) convertView
						.findViewById(R.id.xianshi2);
				for (int i = 0; i < area_Main_display_Model.getClubs()
						.getClub().size(); i++) {
					
					switch (i) {
					case 0:
						// ImageLoader.getInstance().displayImage(
						// Constants.BadiDownImgUrl
						// + area_Main_display_Model.getClubs()
						// .getClub().get(0).getLogo()
						// + Constants.App9block,
						// clubOverview_item_img_temp1, options);
						
						//如果只有一个俱乐部的话就將另一布局隐藏
						if (Integer.parseInt(area_Main_display_Model.getClubs()
								.getClubsNum()) == 1) {					
							xianshi.setVisibility(View.GONE);
						}
						new BitmapHelp().displayImage(context,
								clubOverview_item_img_temp1,
								Constants.BadiDownImgUrl
										+ area_Main_display_Model.getClubs()
												.getClub().get(0).getLogo()
										+ Constants.App9block);
						clubOverview_item_img_temp1
								.setOnClickListener(new View.OnClickListener() {

									@Override
									public void onClick(View v) {
										// TODO Auto-generated method stub
										Intent intent = new Intent(context,
												ClubHomepageActivity.class);
										intent.putExtra("cid",
												area_Main_display_Model
														.getClubs().getClub()
														.get(0).getId());
										intent.putExtra("c_uid",
												area_Main_display_Model
														.getClubs().getClub()
														.get(0).getUid());
										intent.putExtra("is_join",
												area_Main_display_Model
														.getClubs().getClub()
														.get(0).getIs_joined());
										intent.putExtra("logo",
												area_Main_display_Model
														.getClubs().getClub()
														.get(0).getLogo());
										//
										// "数据是:"+area_Main_display_Model
										// .getClubs().getClub()
										// .get(0).getClub_id()+" "+area_Main_display_Model
										// .getClubs().getClub()
										// .get(0).getUid()+" "+area_Main_display_Model
										// .getClubs().getClub()
										// .get(0).getIs_joined()+" "+area_Main_display_Model
										// .getClubs().getClub()
										// .get(0).getLogo());
										context.startActivity(intent);
									}
								});

						clubOverview_item_OverAddress_temp1
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(0)
										.getOriginate_address());
						clubOverview_item_name_temp1
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(0).getName());
						clubOverview_item_infos_temp1
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(0).getInfo());
						clubOverview_item_addnum_temp1.setText("("
								+ area_Main_display_Model.getClubs().getClub()
										.get(0).getAddnum() + ")");
						clubOverview_item_price_temp1
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(0).getPrice());
						break;
					case 1:
						// ImageLoader.getInstance().displayImage(
						// Constants.BadiDownImgUrl
						// + area_Main_display_Model.getClubs()
						// .getClub().get(1).getLogo()
						// + Constants.App9block,
						// clubOverview_item_img_temp2, options);

						 
							new BitmapHelp().displayImage(context,
									clubOverview_item_img_temp2,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getClubs().getClub()
													.get(1).getLogo()
											+ Constants.App9block);
							clubOverview_item_img_temp2
									.setOnClickListener(new View.OnClickListener() {

										@Override
										public void onClick(View v) {
											// TODO Auto-generated method stub
											// Intent intent = new
											// Intent(context,
											// ClubRigionListActivity.class);
											// intent.putExtra("areaid",
											// area_Main_display_Model
											// .getArea().getId());
											// context.startActivity(intent);

											Intent intent = new Intent(context,
													ClubHomepageActivity.class);
											intent.putExtra("cid",
													area_Main_display_Model
															.getClubs()
															.getClub().get(1)
															.getId());
											intent.putExtra("c_uid",
													area_Main_display_Model
															.getClubs()
															.getClub().get(1)
															.getUid());
											intent.putExtra("is_join",
													area_Main_display_Model
															.getClubs()
															.getClub().get(1)
															.getIs_joined());
											intent.putExtra("logo",
													area_Main_display_Model
															.getClubs()
															.getClub().get(1)
															.getLogo());
											//
											// "数据是:"+area_Main_display_Model
											// .getClubs().getClub()
											// .get(0).getClub_id()+" "+area_Main_display_Model
											// .getClubs().getClub()
											// .get(0).getUid()+" "+area_Main_display_Model
											// .getClubs().getClub()
											// .get(0).getIs_joined()+" "+area_Main_display_Model
											// .getClubs().getClub()
											// .get(0).getLogo());
											context.startActivity(intent);
										}
									});
						

						clubOverview_item_OverAddress_temp2
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(1)
										.getOriginate_address());
						clubOverview_item_name_temp2
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(1).getName());
						clubOverview_item_infos_temp2
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(1).getInfo());
						clubOverview_item_addnum_temp2.setText("("
								+ area_Main_display_Model.getClubs().getClub()
										.get(1).getAddnum() + ")");
						clubOverview_item_price_temp2
								.setText(area_Main_display_Model.getClubs()
										.getClub().get(1).getPrice());
						break;

					default:
						break;
					}
				}
				break;
			case 4:// regionhomepage_import_layout3_background 活动
				convertView = inflater.inflate(
						R.layout.regionhomepage_import_layout3, null);
				if (area_Main_display_Model.getActivity().getActivityNum()
						.equals("0")) {
					convertView.setVisibility(View.GONE);
				}// regionhomepage_import_layout3_datatime
				convertView.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent intent = new Intent(context,
								ActivityReadingActivity.class);
						intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
						intent.putExtra("actId",
								area_Main_display_Model.getActivity()
										.getActivities().get(childPosition)
										.getId());
						System.out.println(area_Main_display_Model
								.getActivity().getActivities()
								.get(childPosition).getAddUserInfo().size());
						// if (activity_Overview_Models.get(position).getA_uid()
						// != null) {
						// intent.putExtra("fq_uid",
						// activity_Overview_Models.get(position)
						// .getA_uid());
						// } else {
						// intent.putExtra("fq_uid",
						// activity_Overview_Models.get(position).getUid());
						// }

						if (area_Main_display_Model.getActivity()
								.getActivities().get(childPosition)
								.getIs_online().equals("1")) {
							intent.putExtra("isOnLine", true);
						} else {
							intent.putExtra("isOnLine", false);
						}

						context.startActivity(intent);
					}
				});
				ImageView regionhomepage_import_layout3_background = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_background);
				ImageView regionhomepage_import_layout3_img1 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_img1);
				ImageView regionhomepage_import_layout3_img2 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_img2);
				ImageView regionhomepage_import_layout3_img3 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_img3);
				ImageView regionhomepage_import_layout3_img4 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_img4);
				ImageView regionhomepage_import_layout3_img5 = (ImageView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_img5);
				TextView regionhomepage_import_layout3_tital = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_tital);
				TextView regionhomepage_import_layout3_datatime = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_datatime);
				TextView regionhomepage_import_layout3_addressname = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_addressname);
				TextView regionhomepage_import_layout3_personnum = (TextView) convertView
						.findViewById(R.id.regionhomepage_import_layout3_personnum);
				// ImageLoader.getInstance().displayImage(
				// Constants.BadiDownImgUrl
				// + area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition)
				// .getImage() + Constants.App9block,
				// regionhomepage_import_layout3_background, options);
				new BitmapHelp().displayImage(context,
						regionhomepage_import_layout3_background,
						Constants.BadiDownImgUrl
								+ area_Main_display_Model.getActivity()
										.getActivities().get(childPosition)
										.getImage() + Constants.App9block);
				regionhomepage_import_layout3_background
						.setOnClickListener(new View.OnClickListener() {

							@Override
							public void onClick(View v) {
								// TODO Auto-generated method stub
								Intent intent = new Intent(context,
										ActivityReadingActivity.class);
								intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
								intent.putExtra(
										"actId",
										area_Main_display_Model.getActivity()
												.getActivities()
												.get(childPosition).getId());
								// if
								// (activity_Overview_Models.get(position).getA_uid()
								// != null) {
								// intent.putExtra("fq_uid",
								// activity_Overview_Models.get(position)
								// .getA_uid());
								// } else {
								// intent.putExtra("fq_uid",
								// activity_Overview_Models.get(position).getUid());
								// }
								if (area_Main_display_Model.getActivity()
										.getActivities().get(childPosition)
										.getIs_online().equals("1")) {
									intent.putExtra("isOnLine", true);
								} else {
									intent.putExtra("isOnLine", false);
								}
								context.startActivity(intent);
							}
						});

				regionhomepage_import_layout3_tital
						.setText(area_Main_display_Model.getActivity()
								.getActivities().get(childPosition).getNames());
				String startTime = CalendarTools.getFormatTime(
						Double.parseDouble((area_Main_display_Model
								.getActivity().getActivities()
								.get(childPosition).getStart_time() + "000")),
						"yyyy.MM.dd");
				String endTime = CalendarTools.getFormatTime(
						Double.parseDouble((area_Main_display_Model
								.getActivity().getActivities()
								.get(childPosition).getEnd_time() + "000")),
						"yyyy.MM.dd");

				regionhomepage_import_layout3_datatime.setText(startTime + "-"
						+ endTime);
				// regionhomepage_import_layout3_datatime.setText(back_time(
				// area_Main_display_Model.getActivity().getActivities()
				// .get(childPosition).getStart_time(), 0)
				// + "."
				// + back_time(
				// area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition)
				// .getStart_time(), 1)
				// + "."
				// + back_time(
				// area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition)
				// .getStart_time(), 2)
				// + "-"
				// + back_time(area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition).getEnd_time(),
				// 0)
				// + "."
				// + back_time(area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition).getEnd_time(),
				// 1)
				// + "."
				// + back_time(area_Main_display_Model.getActivity()
				// .getActivities().get(childPosition).getEnd_time(),
				// 2));
				if (area_Main_display_Model.getActivity().getActivities()
						.get(childPosition).getIs_online().equals("0")) {
					regionhomepage_import_layout3_addressname
							.setText(area_Main_display_Model.getActivity()
									.getActivities().get(childPosition)
									.getAddress());
				} else {
					regionhomepage_import_layout3_addressname.setText("线上主题");
				}

				if (area_Main_display_Model.getActivity().getActivities()
						.get(childPosition).getApplied() != null) {
					regionhomepage_import_layout3_personnum
							.setText(area_Main_display_Model.getActivity()
									.getActivities().get(childPosition)
									.getApplied()
									+ "个");

					for (int i = 0; i < area_Main_display_Model.getActivity()
							.getActivities().get(childPosition)
							.getAddUserInfo().size(); i++) {

						switch (i) {
						case 0:
							// ImageLoader.getInstance()
							// .displayImage(
							// Constants.BadiDownImgUrl
							// + area_Main_display_Model
							// .getActivity()
							// .getActivities()
							// .get(childPosition)
							// .getUser_info()
							// .get(0).getHead()
							// + Constants.appPhoto4img,
							// regionhomepage_import_layout3_img1,
							// options);
							new BitmapHelp().displayImage(
									context,
									regionhomepage_import_layout3_img1,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getActivity()
													.getActivities()
													.get(childPosition)
													.getAddUserInfo().get(0)
													.getHead()
											+ Constants.appPhoto4img);
							break;
						case 1:
							// ImageLoader.getInstance()
							// .displayImage(
							// Constants.BadiDownImgUrl
							// + area_Main_display_Model
							// .getActivity()
							// .getActivities()
							// .get(childPosition)
							// .getUser_info()
							// .get(1).getHead()
							// + Constants.appPhoto4img,
							// regionhomepage_import_layout3_img2,
							// options);
							new BitmapHelp().displayImage(
									context,
									regionhomepage_import_layout3_img2,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getActivity()
													.getActivities()
													.get(childPosition)
													.getAddUserInfo().get(1)
													.getHead()
											+ Constants.appPhoto4img);
							break;
						case 2:
							// ImageLoader.getInstance()
							// .displayImage(
							// Constants.BadiDownImgUrl
							// + area_Main_display_Model
							// .getActivity()
							// .getActivities()
							// .get(childPosition)
							// .getUser_info()
							// .get(2).getHead()
							// + Constants.appPhoto4img,
							// regionhomepage_import_layout3_img3,
							// options);
							new BitmapHelp().displayImage(
									context,
									regionhomepage_import_layout3_img3,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getActivity()
													.getActivities()
													.get(childPosition)
													.getAddUserInfo().get(2)
													.getHead()
											+ Constants.appPhoto4img);
							break;
						case 3:
							// ImageLoader.getInstance()
							// .displayImage(
							// Constants.BadiDownImgUrl
							// + area_Main_display_Model
							// .getActivity()
							// .getActivities()
							// .get(childPosition)
							// .getUser_info()
							// .get(3).getHead()
							// + Constants.appPhoto4img,
							// regionhomepage_import_layout3_img4,
							// options);
							new BitmapHelp().displayImage(
									context,
									regionhomepage_import_layout3_img4,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getActivity()
													.getActivities()
													.get(childPosition)
													.getAddUserInfo().get(3)
													.getHead()
											+ Constants.appPhoto4img);
							break;
						case 4:
							// ImageLoader.getInstance()
							// .displayImage(
							// Constants.BadiDownImgUrl
							// + area_Main_display_Model
							// .getActivity()
							// .getActivities()
							// .get(childPosition)
							// .getUser_info()
							// .get(4).getHead()
							// + Constants.appPhoto4img,
							// regionhomepage_import_layout3_img5,
							// options);
							new BitmapHelp().displayImage(
									context,
									regionhomepage_import_layout3_img5,
									Constants.BadiDownImgUrl
											+ area_Main_display_Model
													.getActivity()
													.getActivities()
													.get(childPosition)
													.getAddUserInfo().get(4)
													.getHead()
											+ Constants.appPhoto4img);
							break;

						default:
							break;
						}
					}
					if (area_Main_display_Model.getActivity().getActivities()
							.get(childPosition).getAddUserInfo().size() == 1) {
						regionhomepage_import_layout3_img1
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img2
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img3
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img4
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img5
								.setVisibility(View.GONE);
					} else if (area_Main_display_Model.getActivity()
							.getActivities().get(childPosition)
							.getAddUserInfo().size() == 2) {
						regionhomepage_import_layout3_img1
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img2
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img3
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img4
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img5
								.setVisibility(View.GONE);
					} else if (area_Main_display_Model.getActivity()
							.getActivities().get(childPosition)
							.getAddUserInfo().size() == 3) {
						regionhomepage_import_layout3_img1
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img2
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img3
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img4
								.setVisibility(View.GONE);
						regionhomepage_import_layout3_img5
								.setVisibility(View.GONE);
					} else if (area_Main_display_Model.getActivity()
							.getActivities().get(childPosition)
							.getAddUserInfo().size() == 4) {
						regionhomepage_import_layout3_img1
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img2
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img3
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img4
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img5
								.setVisibility(View.GONE);
					} else if (area_Main_display_Model.getActivity()
							.getActivities().get(childPosition)
							.getAddUserInfo().size() == 5) {
						regionhomepage_import_layout3_img1
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img2
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img3
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img4
								.setVisibility(View.VISIBLE);
						regionhomepage_import_layout3_img5
								.setVisibility(View.VISIBLE);
					}
				} else {
					regionhomepage_import_layout3_personnum.setText("0个");
					regionhomepage_import_layout3_img1.setVisibility(View.GONE);
					regionhomepage_import_layout3_img2.setVisibility(View.GONE);
					regionhomepage_import_layout3_img3.setVisibility(View.GONE);
					regionhomepage_import_layout3_img4.setVisibility(View.GONE);
					regionhomepage_import_layout3_img5.setVisibility(View.GONE);
				}
				break;
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return convertView;
	}

	// private void add_item(View convertView, LayoutInflater inflater,
	// int childPosition) {
	//
	// }

	private String back_time(String dg, int s) {
		String ds[] = dg.split("-");
		if (ds.length > 0) {
			return ds[s];
		} else {
			return dg;
		}

	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return false;
	}

}
